﻿@{
    Bundle("jquery_timepicker");
    Bundle("jquery_validate");
}
           
<script type="text/javascript">
    jQuery(document).ready(function(){
        jQuery('@ID("#form")').validate({
            rules: {
                orderID: {
                    required: true,
                    digits: true
                },
                total: {
                    required: true
                },
                paidAmount: {
                    required: true
                },
                refundAmount: {
                    required: true
                }
            }
        });
        jQuery('@ID("#txt_issued")').datetimepicker();
    });
</script>
<form id="@ID("form")" action="@Url.Action(Loc.Act("Update").Ctrl("Invoice"))" method="post">
    <input type="hidden" name="flags" value="@JDM.String(Model.Flags)" />
    <table>
        <tr>
            <td>
                <label>#</label>
            </td>
            <td>
                <input type="text" readonly name="id" value="@JDM.Int32(Model.EntityID)" />
            </td>
        </tr>
        <tr>
            <td>
                <label>&#10001;</label>
            </td>
            <td>
                <input type="text" readonly value="@Svc.DateTime((DateTime)JDM.DateTime(Model.CreatedOn))" />
            </td>
        </tr>
        <tr>
            <td>
                <label>&#10002;</label>
            </td>
            <td>
                <input type="text" readonly value="@Svc.DateTime((DateTime)JDM.DateTime(Model.UpdatedOn))" />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.Name("IssuedOn"))</label>
            </td>
            <td>
                <input id="@ID("txt_issued")" type="text" name="issuedOn" value="@Svc.DateTime((DateTime)JDM.DateTime(Model.IssuedOn))" />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.In("Common").Of("Vocab").Name("Guid"))</label>
            </td>
            <td>
                <input type="text" readonly value="@JDM.Guid(Model.Guid)" />
            </td>
        </tr>
        <tr>
            <td>
                <a href="@Url.Action(Loc.Act("Edit").Ctrl("Order").Set(new
                {
                    id = JDM.Int32(Model.Order.EntityID)
                }))" class="ui-icon ui-icon-extlink"></a>
                <label>@T(Res.Name("Order"))</label>
            </td>
            <td>
                <input type="text" name="orderID" value="@JDM.Int32(Model.Order.EntityID)" />
            </td>
        </tr>
        <tr>
            <td>
                <label>
                    @T(Res.Name("Total"), JDM.String(Svc.Localization.Currency.Code))
                </label>
            </td>
            <td>
                <input type="text" name="total" value="@Svc.Price((decimal)JDM.Decimal(Model.Total))" />
            </td>
        </tr>
        <tr>
            <td>
                <label>
                    @T(Res.Name("PaidAmount"), JDM.String(Svc.Localization.Currency.Code))
                </label>
            </td>
            <td>
                <input type="text" name="paidAmount" value="@Svc.Price((decimal)JDM.Decimal(Model.PaidAmount))" />
            </td>
        </tr>
        <tr>
            <td>
                <label>
                    @T(Res.Name("RefundAmount"), JDM.String(Svc.Localization.Currency.Code))
                </label>
            </td>
            <td>
                <input type="text" name="refundAmount" value="@Svc.Price((decimal)JDM.Decimal(Model.RefundAmount))" />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.Name("Status"))</label>
            </td>
            <td>
                <ul class="bar">
                    <li>
                        <input type="radio" disabled @(JDM.HasFlags(Model.Flags, "Canceled") ? "checked" : String.Empty) />
                    </li>
                    <li>
                        <label>@T(Res.In("API").Of("Enum").Of("InvoiceFlags").Name("Canceled"))</label>
                    </li>
                    <li>
                        <input type="radio" disabled @(JDM.HasFlags(Model.Flags, "Pending") ? "checked" : String.Empty) />
                    </li>
                    <li>
                        <label>@T(Res.In("API").Of("Enum").Of("InvoiceFlags").Name("Pending"))</label>
                    </li>
                    <li>
                        <input type="radio" disabled @(JDM.HasFlags(Model.Flags, "Issued") ? "checked" : String.Empty) />
                    </li>
                    <li>
                        <label>@T(Res.In("API").Of("Enum").Of("InvoiceFlags").Name("Issued"))</label>
                    </li>
                    <li>
                        <input type="radio" disabled @(JDM.HasFlags(Model.Flags, "Paid") ? "checked" : String.Empty) />
                    </li>
                    <li>
                        <label>@T(Res.In("API").Of("Enum").Of("InvoiceFlags").Name("Paid"))</label>
                    </li>
                </ul>
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.In("API").Of("Enum").Of("InvoiceFlags").Name("Active"))</label>
            </td>
            <td>
                <input type="checkbox" disabled @(JDM.HasFlags(Model.Flags, "Active") ? "checked" : String.Empty) />
            </td>
        </tr>
    </table>
    <ul class="bar toolbar">
        <li><button class="button" type="submit">@T(Res.In("Common").Of("Act").Name("Submit"))</button></li>
    </ul>
</form>
